Demo

A demo (also called LMP, from the lump file extension) is any recording of a game session that can be played back using the game engine. Internally, it is a sequence of tic commands, keeping track of just the input control states during each frame. Thus, a demo is much more compact than a, or even than a recording of the states of all objects in the level.

Built-in demos
If no game or demo is begun immediately when launching vanilla Doom (either from the in-game menus or by using command line arguments), three built-in demos soon begin to play repeatedly, evoking an arcade game's.

The majority of demos are recorded on the Ultra Violence skill level, and most end with the player's death.

When a GUI launcher, such as the Doom95 front end, is used to start the game, the launcher usually warps to a selected level and the built-in demos are bypassed. They can still be viewed, however, by choosing END GAME from the appropriate menu.

The built-in demos are stored in lumps in the IWAD file named DEMO1, DEMO2, and DEMO3. A PWAD can replace a built-in demo by including a lump with the same name, although an engine crash often results if the new demo is incompatible (see below).

Doom
Each new version of Doom changed the engine in ways which made the existing demos desync, and so they had to be re-recorded (see issues below). The map choice, game-mode and approach to each demo shows a progression in the recorder's thinking about the purpose of the demos and how much of the game should be revealed.

All demos in Doom and Doom II were recorded by John Romero.

Shareware
The shareware releases of Doom necessarily limited the demo loop to maps from Knee-Deep in the Dead. The earliest recorded demos are single player run-throughs and occasionally they show the complete level. Later recordings demonstrate other game modes and the play-style is more "tense": the player takes a lot of damage early on and limps on with very low health. By version 1.6, the players always die before completing the levels.

Registered and Commercial
The earlier versions of demos from the registered games exclusively demonstrate levels from The Shores of Hell and Inferno, perhaps to show the game owner new content, as they will have already seen Knee-Deep in the Dead prior to registering. As later releases of Doom were sold commercially as well as via registering the shareware, Episode 1 demos are brought back into the mix. By version 1.666 there is one demo per episode.

Ultimate Doom introduced a fourth demo, DEMO4.

Commercial ports
There was no demo loop in Doom for Game Boy Advance.

Final Doom
The Final Doom engine was based on Ultimate Doom, which loops through four demos. However, only three demo lumps are provided, so the game crashes after playing DEMO3. This was fixed in the Id Anthology version of Final Doom.

Heretic
Following the pattern set by Shareware Doom, the shareware demos are necessarily restricted to the first episode, and the registered version ignores the first episode and focuses only on registered material.

The demos were not re-recorded for the 1.2 update of Heretic and consequently two of the three in the registered version desynchronise. Despite adding two episodes, no further work was done on demos for Shadow Of The Serpent Riders, the two new episodes are unrepresented and the two desynchronised demos remain.

Strife
Strife: Veteran Edition does not play back a demo during its attract sequence. Instead, a special text screen is displayed which reiterates the back story given in the game's instruction manual.

Custom demos
Players can record demos of their own game sessions. This is done using the -record  command line argument, which places the recording in a file named  .lmp in the Doom program directory. You can also add the -warp  command to start recording from a specific map. A recording can subsequently be played back using the -playdemo  command line argument, where  .lmp is the name of the recorded demo. Unlike in the built-in demo sequence and when using -timedemo (see below), it's possible to toggle the automap mode while using -playdemo, because the feature that brings up the menu when pressing input keys or buttons is disabled.

These demo files can then be uploaded to s and servers to aid other players in the completion of the game, show off tricks, reveal secrets, or for competitive purposes (see Speedrun). It is also possible to record multiplayer games.

The -timedemo </tt> parameter can be used as an alternative to -playdemo</tt>. This will render every frame in a demo as quickly as possible for benchmarking purposes.

Technical information
A demo lump is a sequence of instructions which tells the game engine what actions the player will perform: when he will take a step forward, turn around, shoot, switch weapons, etc. It is interpreted by the engine as keyboard and mouse input, thereby allowing anyone to watch a recreation of the original recorded actions. While some elements of the game (such as damage done by attacks) are typically randomized, the usage of a pseudorandom number generator ensures they stay the same with every playback.

Doom
The file starts with a header that specifies the map, skill level, and number of players. Versions after 1.2 extend the 7-byte header to 13 (0xD) bytes to also include information about the game version the demo was recorded with, what multiplayer mode was used, whether the, , and parameters were used, and which player's point of view should be used.

Immediately after this header is a series of player actions for each tic encoded in 4 bytes. There are 35 tics in a second. The first 3 bytes encode movement including speed, strafing and turning. The last byte encodes other actions such as using/opening, shooting, and changing weapon in a special format.

For this last byte, game events - namely, saving the game and pausing - are signaled when the highest bit, bit 7, is set to. If so, the lowest two bits are then checked. If the value is, the game issues a pause or unpause command. If the value is, the game saves to the slot encoded in bits 2, 3, and 4, which is treated as a three-bit value from to. If there is a game event, the game does not check for any other button presses.

If the highest bit is not set, the game next looks to see if bit 2 is set. If so, the game executes a weapon change, using the values in bits 3, 4, and 5, treating the value like a 3-bit number, from to, and activating a change to the weapon number key corresponding to one greater than the value, namely, from 1 to 8.

Finally, the game checks for a use command on bit 1, and a fire command on bit 0.

This structure is repeated for every player in the game.

Following the series is a byte at the end of the lump.

Because the demo format is composed of a series of tic commands rather than a video of recorded gameplay, demo lumps are relatively small and were very practical back when computers were slow and Internet bandwidth was scarce. The size of an uncompressed single-player demo lump is 140 bytes per second (or 4 bytes per tic) plus a few (8 or 14) bytes of overhead. Back then, it would certainly have been nearly impossible to distribute demos as video captures due to their large size.

Over the years, a few utility programs have been written to convert LMPs between the original binary format and other formats. One such program is LMPC, which can also be used for of demos (see TAS).

Heretic
The structure in Heretic is similar to Doom, but features additional information as Heretic features three additional types of commands: To store them in tic commands, there are two additional bytes, one for looking and flying, and the other for artifact use.
 * Looking up and down
 * Flying up and down
 * Using inventory items

The header is similar to 1.2 header, and does not store game version or other parameters.

The tic commands take six bytes:

Following the series is a byte at the end of the lump.

Hexen
The header is similar to 1.2 and Heretic header, and does not store game version or other parameters. It does store an episode value, even though it is irrelevant. However, Hexen supports up to eight players instead of being limited to four.

The tic commands take six bytes, as in Heretic. They did not change the structure of the command byte, with only four weapon slots, Hexen needed only two bits to encode the weapon change, which effectively makes bits 5 and 6 unused. However, they added two additional actions, jumping and suicide, which could have fit there but which they instead placed on the upper bits of the artifact byte. Puzzle items are lumped with artifacts.

Following the series is a byte at the end of the lump.

Strife
The structure in Strife is similar to the post-1.2 version of Doom's demos, but it omits the episode entirely. As a result, Strife demos have odd sizes, while all other demos have even sizes.

Like in Heretic and Hexen, the tic commands take six bytes, with a byte used for additional player actions and another used to store inventory actions.

Following the series is a byte at the end of the lump.

Demo issues
With few exceptions, demos can only be played back with the same versions of the Doom IWAD and executable or source port as those used during recording. If a demo is played on a different source port, using a different WAD(s), or even with a different version of the same source port or IWAD, it may refuse to run, or the actions of the player in the demo may become nonsensical, with the Doomguy crashing into walls and shooting apparently at random. This is known as a "desync", and indicates that the demo is not compatible with the playback method being used.

Display commands not affecting gameplay, such as chat text and the IDDT cheat code, are not recorded in a LMP file and may be used freely during playback. However, other cheat codes are not recorded either, and will almost certainly corrupt the demo if used during recording, or cause a desync if entered during playback.

Many of the demos on the Internet are of version 1.9 format, because it marks the final versions of the games. Older versions are rarer, as the engine versions they were recorded with are obsolete and did not have as much exposure to dedicated players over time. The idgames archive, for example, purged a number of older demos at one point, keeping only demos of the latest version. Additionally, this is the format used in Compet-n, the premier speedrunning site for demos in the original levels of the games. Newer demo sites do include a good number recordings for source ports, however, especially of levels from user-made PWADs.

For some players, it is not practical or even possible to use the original Doom executables to play demos. The original executables were written for, and require DOS or a DOS-like OS environment to function properly. While this has been made easier with the development of the multi-platform emulator, there are also alternatives among the source ports, as most, though not all, demos recorded with id Software's DOS executables will play properly in PrBoom, the Eternity Engine, or Chocolate Doom because these ports are specifically designed to emulate vanilla Doom as closely as possible. On the other hand, an assortment of modern source ports, such as Doomsday or ZDoom, do not record demos in Doom's original demo format, because their movement code requires the recording of extra data (such as Y-axis viewpoints and, jumping, or even flat heights and thing dispositions as in a savegame) even if the associated features are not being utilised.

Other issues that can affect recording or playback:
 * Demo desyncing caused by bouncing Lost Souls
 * Demo desyncing caused by menu access
 * Turning resolution is lowered when recording demos